package com.ff.javamonkey.ui.adapter;

import android.content.Context;
import android.widget.BaseAdapter;

import com.ff.javamonkey.sqlite.type.Group;
import com.ff.javamonkey.sqlite.type.JavaMonkeyType;

public abstract class BaseGroupAdapter<T extends JavaMonkeyType> extends BaseAdapter {

	Group<T> group = null;
	
	public BaseGroupAdapter(Context ctx) {
		
	}
	
	public int getCount() {
		return (group == null) ? 0 : group.size();
	}
	
	public Object getItem(int position) {
		return group.get(position);
	}
	
	public long getItemId(int position) {
		return position;
	}
	
	@Override
	public boolean hasStableIds() {
		return true;
	}
	
	@Override
	public boolean isEmpty() {
		return (group == null) ? true : group.isEmpty();
	}
	
	public void setGroup(Group<T> g) {
		group = g;
		notifyDataSetInvalidated();
	}
}
